package com.cat.dao.common.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.cat.dao.common.BizWorkflowDao;
import com.cat.entity.BizWorkflow;

@Repository
@SuppressWarnings("unchecked")
public class BizWorkFlowDaoImpl extends BaseDaoImpl<BizWorkflow, Integer>
		implements BizWorkflowDao {

	@Override
	public List<BizWorkflow> getByDeploymentId(Integer deploymentId) {
		Criteria cri = getSession().createCriteria(BizWorkflow.class);
		cri.add(Restrictions.eq("deploymentId", deploymentId));
		if (cri.list() != null && cri.list().size() > 0) {
			return cri.list();
		}
		return null;
	}

	@Override
	public List<BizWorkflow> getByWorkflowName(String workflowName) {
		Criteria cri = getSession().createCriteria(BizWorkflow.class);
		cri.add(Restrictions.eq("workflowName", workflowName));
		if (cri.list() != null && cri.list().size() > 0) {

			return cri.list();
		}
		return null;
	}

}
